<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <script>
        window.onload=function(){
            //全局声明组件
            Vue.component('my-child',{
                data(){
                    return{
                        
                    }
                },
                methods:{},
                
                template:`
                    <div>
                        <h1>child</h1>
                    </div>
                `
            });
            new Vue({
                el:'#app',
                data:{},
                methods:{},
                components:{
                    'my-parent':{
                        data(){
                            return{
                                num:10,
                                user:{
                                    name:'lisi',
                                    age:20
                                },
                                list:[1,2,3,4,5,6]
                            }
                        },
                        template:`
                            <div>
                                <p><slot :user='user' :list='list'>default</slot></p>
                                <p><slot name='header'>hello</slot></p>
                                <p><slot name='footer'>hello</slot></p>
                                <h1>parent</h1>
                                <my-child></my-child>
                            </div>
                        `
                    }
                }
            });
        }
    </script>
</head>
<body>
    <div id="app">
        <my-parent>
            <template v-slot:default='scope'>
                {{scope.user.name}}
                {{scope.list}}
            </template>
            <template v-slot:header>world</template>
            <template v-slot:footer>hhhhh</template>
        </my-parent>
    </div>
</body>
</html>